# Copyright 2016 The Fuchsia Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set(REPORT_MASTER_PB_GO "${CMAKE_BINARY_DIR}/go-proto-gen/src/analyzer/report_master/report_master.pb.go")
set_source_files_properties(${REPORT_MASTER_PB_GO} PROPERTIES GENERATED TRUE)

# Build end-to-end tests
set(REPORT_CLIENT_SRC "${CMAKE_SOURCE_DIR}/tools/go/src/report_client/report_client.go")
set(COBALT_E2E_TEST_SRC "${CMAKE_CURRENT_SOURCE_DIR}/src/cobalt_e2e_test.go")
set(COBALT_E2E_TEST_BINARY ${DIR_END_TO_END_TESTS}/cobalt_e2e_test)

add_custom_command(OUTPUT ${COBALT_E2E_TEST_BINARY}
    COMMAND ${GO_BIN} test -c -o ${COBALT_E2E_TEST_BINARY}
            ${COBALT_E2E_TEST_SRC}
    DEPENDS ${COBALT_E2E_TEST_SRC}
    DEPENDS ${REPORT_CLIENT_SRC}
    DEPENDS ${REPORT_MASTER_PB_GO}
    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)

add_custom_target(build_e2e_tests ALL
      DEPENDS ${COBALT_E2E_TEST_BINARY}
)
